package com.yequan.hbb.utils;

import android.widget.TextView;

import com.google.gson.Gson;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Observable;

/**
 * Created by Administrator on 2016/10/13.
 */

public class ServerUtil {

    private static final  String BASEURL="http://api.hongbeibang.com/";
    private static Retrofit retrofit = new Retrofit.Builder().baseUrl(BASEURL)
            .addConverterFactory(GsonConverterFactory.create(new Gson()))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();

    private static <T> T getServer(Class<T>  t){
        return retrofit.create(t);
    }
    public static <T> T  createHttpRequest(Class<T> t) {

        T server = (T) ServerUtil.getServer(t);

        return server;
    }
    /*
      public void getListMoveTop(Action1 success,Action1 error, int start, int count) {

        Observable<MoveEntry> listMoveTop = BaseServer.getServer(Servers.class).getListMoveTop(start, count);

        listMoveTop.observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(success,error);

    }
    public Observable<MoveEntry> getListMoveTopW( int start, int count) {

        Observable<MoveEntry> listMoveTop = BaseServer.getServer(Servers.class).getListMoveTop(start, count);

        listMoveTop = listMoveTop.observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io());//.subscribe(action1);

        return listMoveTop;

    }
     */
}
